﻿@model IEnumerable<HotelManageSystem.Models.ClientInfoModel>
@{
    ViewBag.Title = "ShowAllClientInfo";
    Layout = "~/Views/Shared/_Template2.cshtml";
}
@section Head{
    <link href="../../Content/TelerikGrid.css" rel="stylesheet" type="text/css" />
}
@{
  
    Html.Telerik().Grid(Model).Name("Grid").DataKeys(key => key.Add(r => r.ID))
                            
                             .DataBinding(dataBind => dataBind.Ajax()
                                                             .OperationMode(GridOperationMode.Client)
                                                             .Select("ShowAllClientInfoAjax", "Client")
                                                             .Update("UpdateClient", "Client")
                                                             .Delete("DeleteClient", "Client")
                                                            )
                             .Columns(columns =>
                                     {
                                         columns.Bound(r => r.ID).Title("客户编号").Width(260).HtmlAttributes(new { style = "text-align: center" }).ReadOnly(true);
                                         columns.Bound(r => r.Name).Title("名称").Width(100).HtmlAttributes(new { style = "text-align:center" });
                                         columns.Bound(r => r.ClientTypeName).Title("类型").Width(100).HtmlAttributes(new { style = "text-align:center" });
                                         columns.Bound(r => r.Sex).Title("性别").Width(50).HtmlAttributes(new { style = "text-align: center" });
                                         columns.Bound(r => r.CertificateTypeName).Title("证件").Width(100).HtmlAttributes(new { style = "text-align:center" });
                                         columns.Bound(r => r.CertID).Title("身份证号").Width(180).HtmlAttributes(new { style = "text-align:center" });
                                         columns.Bound(r => r.Address).Title("地址").Width(300).HtmlAttributes(new { style = "text-align: center" });
                                         columns.Bound(r => r.PresentAddress).Title("现居住地").Width(300).HtmlAttributes(new { style = "text-align:center" });
                                         columns.Bound(r => r.Telphone).Title("电话号码").Width(150).HtmlAttributes(new { style = "text-align:center" });
                                         columns.Bound(r => r.Vocation).Title("职业").Width(100).HtmlAttributes(new { style = "text-align: center" });
                                         columns.Bound(r => r.CompanyName).Title("公司").Width(80).HtmlAttributes(new { style = "text-align:center" });
                                         columns.Bound(r => r.Birthday).Title("出生日期").Width(150).HtmlAttributes(new { style = "text-align:center" }).Format("{0:yyyy-MM-dd}");
                                         columns.Bound(r => r.AdvancePayment).Title("预定费用").Width(100).HtmlAttributes(new { style = "text-align: center" });
                                         columns.Bound(r => r.HotelingDays).Title("入住几天").Width(100).HtmlAttributes(new { style = "text-align:center" });
                                         columns.Bound(r => r.IsCheckOut).Title("是否已经退房").Width(100).HtmlAttributes(new { style = "text-align:center" });
                                         columns.Bound(r => r.IsFreeze).Title("注销").Width(100).HtmlAttributes(new { style = "text-align:center" });
                                         //columns.Bound(r => r.Memo).Title("备注").Width(200).HtmlAttributes(new { style = "text-align:center" });

                                         columns.Command(command =>
                                                                 {
                                                                     command.Edit().ButtonType(GridButtonType.ImageAndText);
                                                                     command.Delete().ButtonType(GridButtonType.ImageAndText);
                                                                 }
                                                         ).Width(200).HtmlAttributes(new { style = "text-align:center" }).Title("操作");
                                     }
                                     )
                             .Editable(e => e.Mode(GridEditMode.PopUp))
                             .Pageable(page => page.Style(GridPagerStyles.NextPreviousAndNumeric)
                                                                       .Position(GridPagerPosition.Bottom)
                                                                       .PageSize(12))
                             .Sortable()
                             .Filterable()
                             .ClientEvents(e => e.OnEdit("OnEdit"))
                                            
                             .Scrollable(scrolling => scrolling.Height(435))
                             .Render();
   
}


<script type="text/javascript">
    function OnEdit() {
        //给input增加属性和样式
        $("#ID").attr("readonly", "readonly");
        $("#ID").css({ "background-color": "yellow" });
    }
</script>

